package com.yuwei.module_parking.adapter

import android.graphics.Color
import com.bw.lib_common.entity.ParkingEntity
import com.bw.lib_common.entity.ParkingEntityItem
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.yuwei.module_parking.R

class ParkingAdapter: BaseQuickAdapter<ParkingEntityItem, BaseViewHolder>(R.layout.parking_item) {
    override fun convert(holder: BaseViewHolder, item: ParkingEntityItem) {



        if (item.spaceStatus == "空闲"){
            holder.setText(R.id.parking_item_wz,item.spaceNumber)
            holder.setText(R.id.parking_item_type,item.spaceStatus)
                .setTextColor(R.id.parking_item_type,Color.parseColor("#68C48A"))
                .setBackgroundResource(R.id.parking_item_type,R.drawable.parking_item_bg1)
            holder.setText(R.id.parking_item_text1,"所属区域:"+item.areaName)
            holder.setText(R.id.parking_item_text2,"车位类型:"+item.spaceType)
            holder.setGone(R.id.parking_item_text3,true)
        }
        if (item.spaceStatus == "已占用"){
            holder.setText(R.id.parking_item_wz,item.spaceNumber)
            holder.setText(R.id.parking_item_type,item.spaceStatus)
                .setTextColor(R.id.parking_item_type,Color.parseColor("#497DEE"))
                .setBackgroundResource(R.id.parking_item_type,R.drawable.parking_item_bg2)
            holder.setText(R.id.parking_item_text1,"所属区域:"+item.areaName)
            holder.setText(R.id.parking_item_text2,"车位类型:"+item.spaceType)
            holder.setVisible(R.id.parking_item_text3,true)
            holder.setVisible(R.id.parking_item_text4,true)
            holder.setText(R.id.parking_item_text3,"使用人:"+item.areaName)
            holder.setText(R.id.parking_item_text4,"车牌号:"+item.licensePlate)
//            val regex = Regex("^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领][A-Z][·]?[A-HJ-NP-Z0-9]{4,5}([A-HJ-NP-Z0-9挂学警港澳])?\$")
//            if (!item.licensePlate.isNullOrEmpty()){
//                if (regex.matches(item.licensePlate)){
//
//                }
//            }

        }
        if (item.spaceStatus == "维护中"){
            holder.setText(R.id.parking_item_wz,item.spaceNumber)
            holder.setText(R.id.parking_item_type,item.spaceStatus)
                .setTextColor(R.id.parking_item_type,Color.parseColor("#DBB052"))
                .setBackgroundResource(R.id.parking_item_type,R.drawable.parking_item_bg3)
            holder.setText(R.id.parking_item_text1,item.areaName)
            holder.setText(R.id.parking_item_text2,item.spaceType)
        }
    }
}